import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

//返回按钮
class GoBackButton extends StatelessWidget {
  const GoBackButton({
    Key? key,
    this.color = Colors.white,
    this.padding,
    this.callback,
  }) : super(key: key);
  final Color color;
  final EdgeInsets? padding;
  final Function? callback;

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        if (callback != null) {
          callback?.call();
        } else {
          Get.back();
        }
      },
      behavior: HitTestBehavior.translucent,
      child: Container(
        height: kToolbarHeight.w,
        alignment: Alignment.center,
        padding: padding,
        child: Image.asset(
          'images/ic_back.png',
          height: 16.w,
          width: 16.w,
          color: color,
        ),
      ),
    );
  }
}
